#include "EpilAssignStatementCode.h"
#include "EpilOutputHelper.h"
#include <stdexcept>
#include <algorithm>
#include "EpilPointerHelper.h"

using namespace std;


EpilAssignStatementCode::EpilAssignStatementCode( const EpilLexLocation & location )
: EpilStatementCodeBase( location )
{
}


EpilAssignStatementCode::~EpilAssignStatementCode()
{
	EpilPointerHelper::DeleteItemsAndClear( m_assignees );
	EpilPointerHelper::DeleteItemsAndClear( m_assigners );
}


tstring EpilAssignStatementCode::ToEpilCode( int indent ) const
{
	tstringstream ret;
	ret << EpilOutputHelper::GetIndent( indent );

	if( m_assignees.empty() )
	{
		throw runtime_error( "No assignee?!" );
	}
	ret << EpilOutputHelper::GetListOutput( m_assignees, t(", ") );

	ret << t(" = ");

	if( m_assigners.empty() )
	{
		throw runtime_error( "No assigner?!" );
	}
	ret << EpilOutputHelper::GetListOutput( m_assigners, t(", ") );

	return ret.str();
}